package com.vma.lottery.common;

import com.vma.lottery.vo.CodeVo;

import java.util.*;

/**
 * Created by chenzui on 2017/3/27.
 */
public class ChineseDate {
    static String[][] year = {

//            {"猴","鸡","狗","猪","鼠","牛","虎","兔","龙","蛇","马","羊"},
//            {"鸡","狗","猪","鼠","牛","虎","兔","龙","蛇","马","羊","猴"},
            {"鼠","猪","狗","鸡","猴","羊","马","蛇","龙","兔","虎","牛"},//2016
            {"牛","鼠","猪","狗","鸡","猴","羊","马","蛇","龙","兔","虎"},//2016
            {"虎","牛","鼠","猪","狗","鸡","猴","羊","马","蛇","龙","兔"},//2016
            {"兔","虎","牛","鼠","猪","狗","鸡","猴","羊","马","蛇","龙"},//2016
            {"龙","兔","虎","牛","鼠","猪","狗","鸡","猴","羊","马","蛇"},//2016
            {"蛇","龙","兔","虎","牛","鼠","猪","狗","鸡","猴","羊","马"},//2016
            {"马","蛇","龙","兔","虎","牛","鼠","猪","狗","鸡","猴","羊"},//2016
            {"羊","马","蛇","龙","兔","虎","牛","鼠","猪","狗","鸡","猴"},//2016
            {"猴","羊","马","蛇","龙","兔","虎","牛","鼠","猪","狗","鸡"},//2016
            {"鸡","猴","羊","马","蛇","龙","兔","虎","牛","鼠","猪","狗"},//2017
            {"狗","鸡","猴","羊","马","蛇","龙","兔","虎","牛","鼠","猪"},//2017
            {"猪","狗","鸡","猴","羊","马","蛇","龙","兔","虎","牛","鼠"},//2017

    };

    public static String getChineseYear(Integer y,Integer code){
        String chinaeseYear ="";
        if(y > 2008){
            int t = (y-2008)%12;
//            String[] tmp = year[0];
            int j = code%12 > 0 ? code%12:11;

            chinaeseYear = year[t][j-1];
        }else {
            int t = (2008-y)%12;
//            String[] tmp = year[0];
            int j = code%12 > 0 ? code%12:11;

            chinaeseYear = year[t][j-1];
        }
        return chinaeseYear;
    }

    public static List number2sx(){
        List resultList = new ArrayList();
        Map result = new HashMap();
        Calendar calendar = Calendar.getInstance();
        int y = calendar.get(Calendar.YEAR);
        String[] chinaeseYear;
        if(y > 2008){
            int t = (y-2008)%12;
            chinaeseYear = year[t];
        }else {
            int t = (2008-y)%12;
            chinaeseYear = year[t];
        }
        CodeVo[] codes = new CodeVo[49];
        for (int i=1;i<=49;i++) {
            CodeVo tmp = new CodeVo();
            tmp.setCode(i);
            codes[i-1] = tmp;
        }
//        List tmpList = new ArrayList();
        Map tmp = new HashMap();
        for (int j=0;j<12;j++){
            List tmpList = new ArrayList();
            tmpList.add(codes[j]);
            tmpList.add(codes[j+12]);
            tmpList.add(codes[j+24]);
            tmpList.add(codes[j+36]);
            if(j == 0){
                tmpList.add(codes[j+48]);
            }
            tmp.put(chinaeseYear[j],tmpList);

        }
        Map map1 = new HashMap();
        map1.put("鼠",tmp.get("鼠"));
        resultList.add(map1);

        Map map2 = new HashMap();
        map2.put("牛",tmp.get("牛"));
        resultList.add(map2);

        Map map3 = new HashMap();
        map3.put("虎",tmp.get("虎"));
        resultList.add(map3);

        Map map4 = new HashMap();
        map4.put("兔",tmp.get("兔"));
        resultList.add(map4);

        Map map5 = new HashMap();
        map5.put("龙",tmp.get("龙"));
        resultList.add(map5);

        Map map6 = new HashMap();
        map6.put("蛇",tmp.get("蛇"));
        resultList.add(map6);

        Map map7 = new HashMap();
        map7.put("马",tmp.get("马"));
        resultList.add(map7);

        Map map8 = new HashMap();
        map8.put("羊",tmp.get("羊"));
        resultList.add(map8);

        Map map9 = new HashMap();
        map9.put("猴",tmp.get("猴"));
        resultList.add(map9);

        Map map10 = new HashMap();
        map10.put("鸡",tmp.get("鸡"));
        resultList.add(map10);

        Map map11 = new HashMap();
        map11.put("狗",tmp.get("狗"));
        resultList.add(map11);

        Map map12 = new HashMap();
        map12.put("猪",tmp.get("猪"));
        resultList.add(map12);



        return resultList;
    }


}
